package com.yanzhengwu.boot.core.common.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;


/**
 * 描述:
 *
 * @author yanzhengwu
 * @create 2022-11-24 19:30
 */
@Component
public class SpringContextUtil implements ApplicationContextAware {

    private static ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        SpringContextUtil.applicationContext = applicationContext;

    }

    public String[] getBeanNames(){
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for (String b : beanDefinitionNames){
            System.out.println(b);
        }
        return beanDefinitionNames;
    }


}
